package com.xck.infosys.controller;

import com.xck.infosys.entity.User;
import com.xck.infosys.response.CommonReturnType;
import com.xck.infosys.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@Api
public class UserController extends BaseController{

    @Autowired
    private UserService userService;

    @GetMapping("/lists")
    @ApiOperation(value = "查询所有(自带的)",notes = "查询所有用户信息,返回结果")
    public CommonReturnType lists(){
        List<User> users = userService.list();
        CommonReturnType result = CommonReturnType.create(users);
        return result;
    }

    @GetMapping("/findAll")
    @ApiOperation(value = "查询所有(手动扩展的)",notes = "查询所有用户信息,返回结果")
    public CommonReturnType findAll(){
        //测试异常类是否触发
        int i = 1/0;
        List<User> users = userService.findAll();
        CommonReturnType result = CommonReturnType.create(users);
        return result;
    }

}
